/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.s2aei.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Christian
 */
@Entity
@Table(name = "Aluno")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Aluno.findAll", query = "SELECT a FROM Aluno a"),
    @NamedQuery(name = "Aluno.findByAlunoId", query = "SELECT a FROM Aluno a WHERE a.alunoId = :alunoId"),
    @NamedQuery(name = "Aluno.findByMatricula", query = "SELECT a FROM Aluno a WHERE a.matricula = :matricula"),
    @NamedQuery(name = "Aluno.findByCurso", query = "SELECT a FROM Aluno a WHERE a.curso = :curso"),
    @NamedQuery(name = "Aluno.findByPeriodo", query = "SELECT a FROM Aluno a WHERE a.periodo = :periodo")})
public class Aluno implements Serializable {
    @JoinTable(name = "Participante", joinColumns = {
        @JoinColumn(name = "idParticipante", referencedColumnName = "aluno_Id")}, inverseJoinColumns = {
        @JoinColumn(name = "projeto", referencedColumnName = "idProjeto")})
    @ManyToMany
    private List<Projeto> projetoList;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "aluno")
    private Lideres lideres;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "aluno_Id")
    private Integer alunoId;
    @Column(name = "matricula")
    private Integer matricula;
    @Basic(optional = false)
    @Column(name = "curso")
    private String curso;
    @Basic(optional = false)
    @Column(name = "periodo")
    private int periodo;
    @JoinColumn(name = "aluno_Id", referencedColumnName = "user_Id", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Usuario usuario;

    public Aluno() {
    }

    public Aluno(Integer alunoId) {
        this.alunoId = alunoId;
    }

    public Aluno(Integer alunoId, String curso, int periodo) {
        this.alunoId = alunoId;
        this.curso = curso;
        this.periodo = periodo;
    }

    public Integer getAlunoId() {
        return alunoId;
    }

    public void setAlunoId(Integer alunoId) {
        this.alunoId = alunoId;
    }

    public Integer getMatricula() {
        return matricula;
    }

    public void setMatricula(Integer matricula) {
        this.matricula = matricula;
    }

    public String getCurso() {
        return curso;
    }

    public void setCurso(String curso) {
        this.curso = curso;
    }

    public int getPeriodo() {
        return periodo;
    }

    public void setPeriodo(int periodo) {
        this.periodo = periodo;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (alunoId != null ? alunoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Aluno)) {
            return false;
        }
        Aluno other = (Aluno) object;
        if ((this.alunoId == null && other.alunoId != null) || (this.alunoId != null && !this.alunoId.equals(other.alunoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.s2aei.model.Aluno[ alunoId=" + alunoId + " ]";
    }

    @XmlTransient
    public List<Projeto> getProjetoList() {
        return projetoList;
    }

    public void setProjetoList(List<Projeto> projetoList) {
        this.projetoList = projetoList;
    }

    public Lideres getLideres() {
        return lideres;
    }

    public void setLideres(Lideres lideres) {
        this.lideres = lideres;
    }
    
}
